//引入vuex
import { createStore } from "vuex";
//引入vuex可持久化插件
import VuexPersistence from "vuex-persist";

const vuexLocal = new VuexPersistence({
  storage: window.localStorage,
});

const store = createStore({
  state() {
    return {
      username: "xiaohui",
    };
  },

  mutations: {
    servername(state, val) {
      state.username = val;
    },
  },
  actions: {
    setuserinfo(context, val) {
      context.commit("servername", val);
    },
  },
  plugins: [vuexLocal.plugin],
});

export default store;
